package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.OperationRecord;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class OperationRecordVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "项目id")
    private Integer projectId;

    @ApiModelProperty(value = "操作时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date operationTime;

    @ApiModelProperty(value = "操作人")
    private Integer adminId;

    @ApiModelProperty(value = "操作描述")
    private String comment;

    @ApiModelProperty(value = "操作类型")
    private Integer actionType;

    @ApiModelProperty(value = "流程类型")
    private Integer operationType;

    @ApiModelProperty(value = "审核备注原因")
    private String remark;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static OperationRecord convert(OperationRecordVO vo) {
        OperationRecord entity = new OperationRecord();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<OperationRecord> convertList(List<OperationRecordVO> list) {
        List<OperationRecord> resultList = new ArrayList<>();
        for (OperationRecordVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
